<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #app {
        width: 600px;
        margin: 10px auto;
      }

      .tb {
        border-collapse: collapse;
        width: 100%;
      }

      .tb th {
        background-color: #0094ff;
        color: white;
      }

      .tb td,
      .tb th {
        padding: 5px;
        border: 1px solid black;
        text-align: center;
      }
    </style>
  </head>

  <body>
    <div id="app">
      <table class="tb">
        <th>欢迎光临 vue开发的收银系统_水果店</th>
        <tr>
          <td>苹果 {{applePerWeight}}￥/斤,折扣&lt; 8 折 ></td>
        </tr>
        <tr>
          <td>
            <span>请输入你要购买的斤数</span>
            <input type="number" v-model="weight" />
          </td>
        </tr>
        <tr>
          <td><button @click="cal">结账买单~</button></td>
        </tr>
        <tr>
          <td>结账单: 总价: {{total}} ￥元 折后价: {{total * 0.8}}￥元 省了:{{total - total * 0.8}}￥元</td>
        </tr>
      </table>
    </div>
    <script src="../js/vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          weight: 2,
          applePerWeight: 10,
          total: 0,
        },
        methods: {
          cal() {
            this.total = this.weight * this.applePerWeight;
          },
        },
      });
    </script>
  </body>
</html>
